.select2-container {
  box-sizing: border-box;
  display: inline-block;
  margin: 0;
  position: relative;
  vertical-align: middle;

  .select2-selection--single {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    height: $input-height;
    user-select: none;
    -webkit-user-select: none;

    .select2-selection__rendered {
      display: block;
      padding-top: $input-padding-y;
      padding-right: 20px;
      padding-bottom: $input-padding-y;
      padding-left: $input-padding-x;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .select2-selection__clear {
      position: relative;
    }
  }

  &[dir="rtl"] {
    .select2-selection--single {
      .select2-selection__rendered {
        padding-right: 8px;
        padding-left: 20px;
      }
    }
  }

  .select2-selection--multiple {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    min-height: 32px;
    user-select: none;
    -webkit-user-select: none;

    .select2-selection__rendered {
      display: inline-block;
      overflow: hidden;
      padding-left: 8px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .select2-search--inline {
    float: left;

    .select2-search__field {
      box-sizing: border-box;
      border: none;
      font-size: 100%;
      margin-top: .375rem;
      padding: 0;
      
      &::-webkit-search-cancel-button {
        -webkit-appearance: none;
      }
    }
  }
}

.select2-dropdown {
  background-color: white;
  border: 1px solid #aaa;
  border-radius: 4px;
  box-sizing: border-box;
  display: block;
  position: absolute;
  left: -100000px;
  width: 100%;
  z-index: 1051;
}

.select2-results {
  display: block;
}

.select2-results__options {
  padding: 4px;
  list-style: none;
  margin: 0;
}

.select2-results__option {
  padding: 6px 8px;
  border: 1px solid white;
  border-radius: .25rem;
  user-select: none;
  -webkit-user-select: none;
  &[aria-selected] {
    cursor: pointer;
  }
}

.select2-container--open .select2-dropdown {
  left: 0;
}

.select2-container--open .select2-dropdown--above {
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.select2-container--open .select2-dropdown--below {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.select2-search--dropdown {
  display: block;
  padding: 4px;
  .select2-search__field {
    padding: 4px;
    width: 100%;
    box-sizing: border-box;
    &::-webkit-search-cancel-button {
      -webkit-appearance: none;
    }
  }
  &.select2-search--hide {
    display: none;
  }
}

.select2-close-mask {
  border: 0;
  margin: 0;
  padding: 0;
  display: block;
  position: fixed;
  left: 0;
  top: 0;
  min-height: 100%;
  min-width: 100%;
  height: auto;
  width: auto;
  opacity: 0;
  z-index: 99; // styles required for IE to work
  background-color: #fff;
  filter: alpha(opacity=0);
}

.select2-hidden-accessible {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  -webkit-clip-path: inset(50%) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
  white-space: nowrap !important;
}

// @import "theme/default/layout";
$remove-color: white !default;
$remove-hover-color: white !default;
$remove-width: 20px !default;
$selection-color: $input-color;
$border-color: $input-border-color;
$border-radius: $border-radius;
$focus-border-color: $gray-500;
$container-height: 28px !default;
$selection-bg-top-color: white !default;
$selection-bg-bottom-color: #eeeeee !default;
$container-placeholder-color: #999 !default;
$container-focus-border-color: $primary;
$selection-opened-bg-top-color: $selection-bg-bottom-color !default;
$selection-opened-bg-bottom-color: $selection-bg-top-color !default;
$dropdown-z-index: 1 !default;
$dropdown-bg-color: $selection-bg-top-color !default;
$results-max-height: 200px !default;
$results-nested-padding: 20px !default;
$results-choice-border-hover-color: theme-color-level("primary", -9) !default;
$results-choice-bg-hover-color: theme-color-level("primary", -11) !default;
$results-choice-fg-hover-color: inherit !default;
$results-choice-fg-unselectable-color: $secondary !default;

.select2-container--class {
  .select2-selection--single {
    background-color: $input-bg;
    border: 1px solid $border-color;
    border-radius: $border-radius;
    outline: 0;
    &:focus {
      border: 1px solid $focus-border-color;
    }
    .select2-selection__rendered {
      color: $input-color;
      line-height: $line-height-base;
    }
    .select2-selection__clear {
      cursor: pointer;
      float: right;
      font-weight: bold;
      margin-right: 10px;
    }
    .select2-selection__placeholder {
      color: $input-placeholder-color;
    }
    .select2-selection__arrow {
      border: none;
      border-top-right-radius: $border-radius;
      border-bottom-right-radius: $border-radius;
      height: 2.25rem;
      position: absolute;
      top: 1px;
      right: 1px;
      width: 20px;
      b {
        border-color: #888 transparent transparent transparent;
        border-style: solid;
        border-width: 5px 4px 0 4px;
        height: 0;
        left: 50%;
        margin-left: -4px;
        margin-top: -2px;
        position: absolute;
        top: 50%;
        width: 0;
      }
    }
  }
  &[dir="rtl"] {
    .select2-selection--single {
      .select2-selection__clear {
        float: left;
      }
      .select2-selection__arrow {
        border: none;
        border-right: 1px solid $border-color;
        border-radius: 0;
        border-top-left-radius: $border-radius;
        border-bottom-left-radius: $border-radius;
        left: 1px;
        right: auto;
      }
    }
  }
  &.select2-container--open {
    .select2-selection--single {
      border: 1px solid $focus-border-color;
      .select2-selection__arrow {
        background: transparent;
        border: none;
        b {
          border-color: transparent transparent #888 transparent;
          border-width: 0 4px 5px 4px;
        }
      }
    }
    &.select2-container--above {
      .select2-selection--single {
        border-top: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
      }
    }
    &.select2-container--below {
      .select2-selection--single {
        border-bottom: none;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
      }
    }
  }
  .select2-selection--multiple {
    height: 38px;
    background-color: white;
    border: 1px solid $border-color;
    border-radius: $border-radius;
    cursor: text;
    outline: 0;

    &:focus {
      border: 1px solid $focus-border-color;
    }
    
    .select2-selection__rendered {
      list-style: none;
      margin: 0;
      padding: 0 .375rem;
    }
    .select2-selection__clear {
      display: none;
    }
    .select2-selection__choice {
      color: white;
      background-color: $primary;
      border-radius: $border-radius;
      cursor: default;
      float: left;
      margin-top: .375rem;
      margin-right: .375rem;
      padding: 0 .5rem;
      display: flex;
    }
    .select2-selection__choice__remove {
      display: flex;
      line-height: 20px;
      color: $remove-color;
      cursor: pointer;
      font-weight: bold;
      margin-right: .25rem;
      &:hover {
        color: $remove-hover-color;
      }
    }
  }
  &[dir="rtl"] {
    .select2-selection--multiple {
      .select2-selection__choice {
        float: right;
        margin-left: 5px;
        margin-right: auto;
      }
      .select2-selection__choice__remove {
        margin-left: 2px;
        margin-right: auto;
      }
    }
  }
  &.select2-container--open {
    .select2-selection--multiple {
      border: 1px solid $focus-border-color;
    }
    &.select2-container--above {
      .select2-selection--multiple {
        border-top: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
      }
    }
    &.select2-container--below {
      .select2-selection--multiple {
        border-bottom: none;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
      }
    }
  }
  .select2-search--dropdown {
    .select2-search__field {
      border: 1px solid $border-color;
      outline: 0;
    }
  }
  .select2-search--inline {
    .select2-search__field {
      outline: 0;
      box-shadow: none;
    }
  }

  .select2-dropdown {
    background-color: $dropdown-bg-color;
    border: 1px solid transparent;

    &--above {
      border-bottom: none;
    }
    
    &--below {
      border-top: none;
    }
  }

  .select2-results>.select2-results__options {
    max-height: $results-max-height;
    overflow-y: auto;
  }
  .select2-results__option {
    &[role=group] {
      padding: 0;
    }
    &[aria-disabled=true] {
      color: $results-choice-fg-unselectable-color;
    }
  }
  .select2-results__option--highlighted[aria-selected] {
    border: 1px solid $results-choice-border-hover-color;
    background-color: $results-choice-bg-hover-color;
    color: $results-choice-fg-hover-color;
  }
  .select2-results__group {
    cursor: default;
    display: block;
    padding: 6px;
  }
  &.select2-container--open .select2-dropdown {
    border-color: $focus-border-color;
  }
}